package com.scf.fruit.business.login.controller;

import com.scf.fruit.business.login.bo.LoginBo;
import com.scf.fruit.business.login.po.WxUserReq;
import com.scf.fruit.configuration.web.LoginValid;
import com.scf.fruit.util.ResponseVo;
import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;

/**
 * @author : 孙超飞
 * @title :
 * @description :
 * @copyright :
 * @date : 2018-05-18 14:08
 */
@Controller
@RequestMapping(value = "/login",produces = "application/json")
public class LoginController {

    @Resource
    private LoginBo loginBo;

    @ResponseBody
    @RequestMapping(value ="/requestWX",method = RequestMethod.GET)
    public ResponseVo requestWX(@RequestParam("code") String code){
        return loginBo.login(code);
    }

    @ResponseBody
    @RequestMapping(value ="/saveUser",method = RequestMethod.POST)
    public ResponseVo saveUser( @RequestBody WxUserReq req) throws Exception {
        return loginBo.saveUserInfo(req.getCode(),req.getEncryptedData(),req.getIv());
    }

}
